<?php
$this->breadcrumbs=array(
	'Deals'=>array('deal/admin'),
	//$model->customer->getFullName()=>array('customer/view','id'=>$model->customerId),
	$model->deal->referenceNo=>array('deal/view','id'=>$model->dealId),
	'Attachments'=>array('admin','dealId'=>$model->dealId),
	$model->name,
);

$this->menu=array(
//	array('label'=>'List Attachment', 'url'=>array('index')),
//	array('label'=>'Create Attachment', 'url'=>array('create','customerId'=>$model->customerId)),
	array('label'=>'Update Attachment', 'url'=>array('update', 'id'=>$model->id)),
	array('label'=>'Delete Attachment', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),
		'confirm'=>'Are you sure you want to delete this attachment? All files will be deleted!')),
//	array('label'=>'Manage Attachment', 'url'=>array('admin','customerId'=>$model->customerId)),
	array('label'=>'Upload File', 'url'=>array('attachmentFile/create','attachmentId'=>$model->id)),
	array('label'=>'Batch Upload', 'url'=>array('attachmentFile/batch','attachmentId'=>$model->id)),
);
?>

<h1>View Attachment - <?php echo $model->name; ?></h1>

<?php $this->widget('zii.widgets.CDetailView', array(
	'data'=>$model,
	'attributes'=>CMap::mergeArray(array(
//		'id',
		'name',
//		'customerId',
//		'uploadDate',
//		'uploadStaff',
		array(
			'name'=>'createUserId',
			'value'=>$model->createUserId?($model->createUser->firstName.' '.$model->createUser->lastName):'',
		),
		'notes',
	),GlobalConfiguration::isManageMode()?array(
		'hidden:boolean',):array()),
)); ?>

<!--Start of files table-->
<?php
$this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'attachment-file-grid',
	'dataProvider'=>$attachmentFile->search(),
	'filter'=>$attachmentFile,
	'columns'=>array(
		'fileName:text:File',
		array(
			'name'=>'note',
			'type'=>'raw',
			'value'=>'strlen($data->note)>80?substr($data->note,0,79)."...":$data->note'
			//'filter'=>'',
		),
		array(
			//'name'=>'uploadDate',
			//'filter'=>'',
			'header'=>'Upload Date',
			'value'=>'date("d/m/Y",strtotime($data->uploadDate))',
		),
		array(
			'name'=>'createUserId',
			'type'=>'raw',
			'value'=>'$data->createUserId?($data->createUser->firstName." ".$data->createUser->lastName):""',
			'filter'=>'',
		),
		array(
			'type'=>'raw',
			'value'=>'CHtml::link("Download",array("attachmentFile/download","id"=>$data->id))',
		),
		array(
			'type'=>'raw',
			'value'=>'CHtml::link("View",array("attachmentFile/download","id"=>$data->id,"view"=>1),array("target"=>"_blank"))',
		),
		array(
			'class'=>'CButtonColumn',
			'template'=>'{update} {delete}',
			'updateButtonUrl'=>'Yii::app()->controller->createUrl("attachmentFile/update",array("id"=>$data->primaryKey))',
			'deleteButtonUrl'=>'Yii::app()->controller->createUrl("attachmentFile/delete",array("id"=>$data->primaryKey))',
		),
	),
));
?>